// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import VueCookies from 'vue-cookies'
import Axios from 'axios'
import App from './App'
import router from './router'
import VueClipboard from 'vue-clipboard2'
import 'mint-ui/lib/style.css'
import 'lib-flexible'
import './assets/stylus/main.styl'
import './assets/stylus/mixin.styl'
import {eventBus} from './assets/js/common'

import {Swipe, SwipeItem, Progress, Loadmore, Indicator, MessageBox, InfiniteScroll, Field, Spinner, Toast} from 'mint-ui'

function isPc() {
  let userAgentInfo = navigator.userAgent
  let Agents = ['Android', 'iPhone', 'SymbianOS', 'Windows Phone', 'iPad', 'iPod']
  let agent = navigator.userAgent.toLowerCase()
  let isWechat = agent.indexOf('micromessenger')
  let flag = true
  if (isWechat > 0) {
    flag = false
    return false
  }
  for (let i = 0; i < Agents.length; i++) {
    if (userAgentInfo.indexOf(Agents[i]) > 0) {
      flag = false
      break
    }
  }
  if (flag) {
    document.getElementsByTagName('html')[0].style.fontSize = '37.5px'//iphone6 的屏幕大小
    document.getElementsByTagName('body')[0].style.overflow = 'hidden'
  }
  return flag
}

function isWebkit() {
  let flag = false
  let userAgentInfo = navigator.userAgent
  if (userAgentInfo.indexOf('WebKit') > 0) {
    flag = true
  }
  return flag
}

let PC = isPc()
let webkit = isWebkit()
Vue.config.productionTip = false
Vue.prototype.PC = PC
Vue.prototype.isWebkit = webkit
Vue.prototype.$http = Axios
Vue.prototype.eventBus = eventBus
Vue.prototype.ERROR_OK = 0
Vue.prototype.Indicator = Indicator
Vue.prototype.Toast = Toast
Vue.prototype.MessageBox = MessageBox
Vue.prototype.userInfo = []
Vue.use(VueClipboard)
Vue.use(InfiniteScroll)
Vue.use(VueCookies)

Vue.component(Swipe.name, Swipe)
Vue.component(SwipeItem.name, SwipeItem)
Vue.component(Progress.name, Progress)
Vue.component(Loadmore.name, Loadmore)
Vue.component(Field.name, Field)
Vue.component(Spinner.name, Spinner)

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  eventBus,
  components: {App},
  template: '<App/>'
})
